package com.tron.io;

import java.io.*;

public class DataInputStreamStart {
    public static void main(String[] args) throws Exception {
        // 把已经读取的内容刷会流中
        PushbackInputStream pbin;
        DataInputStream dataInputStream = new DataInputStream(pbin = new PushbackInputStream(new FileInputStream("src/main/java/com/tron/io/json.dat")));
        if (checkEOF(dataInputStream, pbin)) {
            System.out.println(dataInputStream.readBoolean());
        }
        if (checkEOF(dataInputStream, pbin)) {
            System.out.println(dataInputStream.readInt());
        }
        if (checkEOF(dataInputStream, pbin)) {
            System.out.println(dataInputStream.readInt());
        }
        if (checkEOF(dataInputStream, pbin)) {
            System.out.println(dataInputStream.readInt());
        }
    }

    public static Boolean checkEOF(InputStream d,PushbackInputStream p) throws IOException {
        int read = d.read();
        System.out.println("判断是否有可读取内容==="+read);
        if (read != -1) {
            p.unread(read);
            return true;
        }
        return false;
    }
}
